$(function(){
	//下一页
	$(".ClassXia").click(function(){
		if(pageCount>curPage){
			//清除
			$(".productlist-x .metlist li").remove();
			curPage++;
			$(".dqy").text(curPage);
			inventoryinfoselectAll();
		}
		else if(pageCount==curPage){
			layer.msg('亲，已经是最后了!', {icon: 7, time: 2000});
		}
		
	})
	//上一页
	$(".ClassShang").click(function(){
		if(curPage>1){
			//清除
			$(".productlist-x .metlist li").remove();
			curPage--;
			$(".dqy").text(curPage);
			inventoryinfoselectAll();
		}
		else if(curPage==1){
			layer.msg('亲，已经是首页了!', {icon: 7, time: 2000});
		}
		
	})
	//首页
	$(".ClassShou").click(function(){
		//清除
		$(".productlist-x .metlist li").remove();
		curPage=1;
		$(".dqy").text(curPage);
		inventoryinfoselectAll();
	})
	//尾页
	$(".ClassWei").click(function(){
		//清除
		$(".productlist-x .metlist li").remove();
		curPage=pageCount;
		$(".dqy").text(curPage);
		inventoryinfoselectAll();
	})
	inventoryinfoselectAll();
})

var curPage=1;//当前页码
	var getPageCount=0;//总条数
	var pageCount=0;//总页数
function  inventoryinfoselectAll(){
	var pageSize=10;//每页条数
	
	var itiname="";//模糊查询的值
	//查询总数
	$.ajax({
		type:"post",
		url:"inventoryinfoAction!pageCount",
		async:false,
		data:{"itiname":itiname},
		dataType:"json",
		success:function(msg){
			getPageCount=msg;
		}
	});
	pageCount=getPageCount/pageSize;
	
	if(getPageCount%pageSize!=0){
		pageCount=Math.ceil(pageCount);
	}
	
	//总页数
	$(".zys").text(pageCount);
	//总条数
	$(".zts").text(getPageCount);
	//当前页
	$(".dqy").text(curPage);
	var page=$(".dqy").text();
	$.ajax({
		type:"post",
		url:"inventoryinfoAction!findAll",
		data:{"page":page,"tr":pageSize,"itiname":itiname},
		dataType:"json",
		success:function(msg){
			for(var i=0;i<msg.length;i++){
				//在表中追加一行数据
				var tr="<li class='list' style='width:182px; margin-left:7px; margin-right:7px;'>"+
						"<div>"+
							"<a href='product_Detail.jsp' title='"+msg[i].ptitypeName+"' target='_self' class='img'>"+
								"<img src='admin/images/"+msg[i].iTIPicture+"' alt='"+msg[i].ptitypeName+"' title='"+msg[i].ptitypeName+"' width='160' height='130' />"+
							"</a>"+
							"<h3><a href='product_Detail.jsp' title='"+msg[i].ptitypeName+"' target='_self'>"+msg[i].ptitypeName+"</a></h3>"+
							"<p class='descr'>"+msg[i].iTIEffect+"</p><a href='product13.html' title='汽车检测仪' target='_self' class='more'>查看产品详细</a>"+
						"</div>"+
					"</li>";
				$(".productlist-x .metlist").append(tr);
			}
		}
		
	});
}